<?php
/**
 * APPCore pagination style
 * 
 * @preview  « Previous  1 2 … 5 6 7 8 9 10 11 12 13 14 … 25 26  Next »
 */
?>
<div class="pagination pagination-right">
	<ul>
	
	<?php if ($this->previous_page): ?>
        <li><a title="<?php echo $this->translate('PAGINATION_PREV'); ?>" href="<?php echo $this->url(array_merge(array('page' => $this->previous_page), $this->pagingParams)); ?>"><?php echo $this->translate('PAGINATION_PREV'); ?></a></li>
	<?php else: ?>
		<li><a title="<?php echo $this->translate('PAGINATION_PREV'); ?>" href="javascript:;"><?php echo $this->translate('PAGINATION_PREV'); ?></a></li>
	<?php endif ?>

	<?php if ($this->total_pages < 13): /* « Previous  1 2 3 4 5 6 7 8 9 10 11 12  Next » */ ?>

		<?php for ($i = 1; $i <= $this->total_pages; $i++): ?>
			<?php if ($i == $this->current_page): ?>
                <li class="active"><a title="<?php echo $i ?>" href="javascript:;"><?php echo $i ?></a></li>
			<?php else: ?>
			    <li><a title="<?php echo $i ?>" href="<?php echo $this->url(array_merge(array('page' => $i), $this->pagingParams)); ?>"><?php echo $i ?></a></li>
			<?php endif ?>
		<?php endfor ?>

	<?php elseif ($this->current_page < 9): /* « Previous  1 2 3 4 5 6 7 8 9 10 … 25 26  Next » */ ?>

		<?php for ($i = 1; $i <= 10; $i++): ?>
			<?php if ($i == $this->current_page): ?>
				<li class="active"><a title="<?php echo $i ?>" href="javascript:;"><?php echo $i ?></a></li>
			<?php else: ?>
				<li><a title="<?php echo $i ?>" href="<?php echo $this->url(array_merge(array('page' => $i), $this->pagingParams)); ?>"><?php echo $i ?></a></li>
			<?php endif ?>
		<?php endfor ?>

		<li><a title="&hellip;" href="javascript:;">&hellip;</a></li>
		<li><a title="<?php echo $this->total_pages - 1 ?>" href="<?php echo $this->url(array_merge(array('page' => $this->total_pages - 1), $this->pagingParams)); ?>"><?php echo $this->total_pages - 1 ?></a></li>
		<li><a title="<?php echo $this->total_pages ?>" href="<?php echo $this->url(array_merge(array('page' =>  $this->total_pages ), $this->pagingParams)); ?>"><?php echo $this->total_pages ?></a></li>

	<?php elseif ($this->current_page > $this->total_pages - 8): /* « Previous  1 2 … 17 18 19 20 21 22 23 24 25 26  Next » */ ?>

        <li><a title="1" href="<?php echo $this->url(array_merge(array('page' => 1), $this->pagingParams)); ?>">1</a></li>
        <li><a title="2" href="<?php echo $this->url(array_merge(array('page' => 2), $this->pagingParams)); ?>">2</a></li>
        <li><a title="&hellip;" href="javascript:;">&hellip;</a></li>

		<?php for ($i = $this->total_pages - 9; $i <= $this->total_pages; $i++): ?>
			<?php if ($i == $this->current_page): ?>
                <li class="active"><a title="<?php echo $i ?>" href="javascript:;"><?php echo $i ?></a></li>
			<?php else: ?>
			    <li><a title="<?php echo $i ?>" href="<?php echo $this->url(array_merge(array('page' => $i), $this->pagingParams)); ?>"><?php echo $i ?></a></li>
			<?php endif ?>
		<?php endfor ?>

	<?php else: /* « Previous  1 2 … 5 6 7 8 9 10 11 12 13 14 … 25 26  Next » */ ?>

		<li><a title="1" href="<?php echo $this->url(array_merge(array('page' => 1), $this->pagingParams)); ?>">1</a></li>
        <li><a title="2" href="<?php echo $this->url(array_merge(array('page' => 2), $this->pagingParams)); ?>">2</a></li>
        <li><a title="&hellip;" href="javascript:;">&hellip;</a></li>

		<?php for ($i = $this->current_page - 5; $i <= $this->current_page + 5; $i++): ?>
			<?php if ($i == $this->current_page): ?>
			    <li class="active"><a title="<?php echo $i ?>" href="javascript:;"><?php echo $i ?></a></li>
			<?php else: ?>
			    <li><a title="<?php echo $i ?>" href="<?php echo $this->url(array_merge(array('page' => $i), $this->pagingParams)); ?>"><?php echo $i ?></a></li>
			<?php endif ?>
		<?php endfor ?>

		<li><a title="&hellip;" href="javascript:;">&hellip;</a></li>
		<li><a title="<?php echo $this->total_pages - 1 ?>" href="<?php echo $this->url(array_merge(array('page' => $this->total_pages - 1), $this->pagingParams)); ?>"><?php echo $this->total_pages - 1 ?></a></li>
		<li><a title="<?php echo $this->total_pages ?>" href="<?php echo $this->url(array_merge(array('page' => $this->total_pages ), $this->pagingParams)); ?>"><?php echo $this->total_pages ?></a></li>

	<?php endif ?>

	<?php if ($this->next_page): ?>
        <li><a title="<?php echo $this->translate('PAGINATION_NEXT'); ?>" href="<?php echo $this->url(array_merge(array('page' => $this->next_page), $this->pagingParams)); ?>"><?php echo $this->translate('PAGINATION_NEXT'); ?></a></li>
	<?php else: ?>
		<li><a title="<?php echo $this->translate('PAGINATION_NEXT'); ?>" href="javascript:;"><?php echo $this->translate('PAGINATION_NEXT'); ?></a></li>
	<?php endif ?>
	
	</ul>
</div>